package com.vogue.supplymall.account.domain.mapper;

import java.util.List;
import java.util.Map;

import com.vogue.supplymall.account.domain.provider.VaildOrganSqlProvider;
import com.vogue.supplymall.common.domain.dto.admin.OrganSearchInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.vogue.supplymall.account.domain.model.BaseCode;
import org.apache.ibatis.annotations.SelectProvider;

/**
 * Created by 崔岳 on 2017-12-1.
 */
@Mapper
public interface CodeMapper extends BaseMapper<BaseCode,Long> {

	/**
	 * 获取所有已经注册用过的系统随机号（100000以下是内部测试使用，可以略过）
	 * @return
	 */
	@Select("select syscode, id from base_code where syscode > 99999 order by syscode")
	public List<Map<Long, Long>> syscodeExisted();
	
	/**
	 * 检查注册号是否存在，存在即合法，否则不合法</br>
	 * tyc</br>
	 * 2017-12-06
	 * @return
	 */
	@Select("select id from base_code where syscode=#{sysCode}")
	public List<Long> checkSysCodeValidity(Long sysCode);
	
	/**
	 * 检查客户注册号是否存在
	 */
	@Select("select syscode from base_code where syscode in (${syscodes})")
	public List<Long> checkSyscodeExist(@Param("syscodes")String sysCodes);

	/**
	 * Find valid organ list.
	 * 开通集团-查询注册账号已申请但没开通的集团
	 *
	 * @return the list
	 */
	@SelectProvider(type = VaildOrganSqlProvider.class, method = "find")
	List<Map<String,Object>> findValidOrgan(OrganSearchInfo organSearchInfo) throws RuntimeException;

	/**
	 * Find valid organ list.
	 * 开通集团-查询注册账号已申请但没开通的集团
	 *
	 * @return the list
	 */
	@SelectProvider(type = VaildOrganSqlProvider.class, method = "findCount")
	Long findValidOrganCount(OrganSearchInfo organSearchInfo) throws RuntimeException;
}
